
#ifndef _LIBRARY_LOG_SERVICE_H__
#define _LIBRARY_LOG_SERVICE_H__

#include "spdlog/spdlog.h"

#define DEFAULT_LOGGER_LEVEL spdlog::level::level_enum::info

class LogService
{

public:
    enum LogType
    {
        UDP_LOG = 0,
        STDOUT_LOG,
        FILE_LOG,
        COLOR_LOG,

        UNKNOWN_LOG
    };

    // Initialize log service with LogType enumeration
    //  0 -- success
    // -1 -- parameter error
    // -2 -- already initialized
    // -3 -- spdlog create sink error
    // -4 -- spdlog expection occurred
    // -5 -- unkown error
    static int init(std::initializer_list<LogType>);

    // Initialize log service with LogType string
    // Surpport string: "udp", "stdout", "file", "color"
    //  0 -- success
    // -1 -- parameter error
    // -2 -- already initialized
    // -3 -- spdlog create sink error
    // -4 -- spdlog expection occurred
    // -5 -- unkown error
    static int init(std::initializer_list<std::string>);

    // Create a logger with level enumeration
    // nullptr -- fail
    // other -- success
    static std::shared_ptr<spdlog::logger> create(const std::string &tag, spdlog::level::level_enum level = DEFAULT_LOGGER_LEVEL);

    // Create a logger with level string
    // Surpport level string: "trace", "debug", "info", "warning", "warn", "error", "err", "critical", "off"
    // nullptr -- fail
    // other -- success
    static std::shared_ptr<spdlog::logger> create(const std::string &tag, const std::string &level);

    static std::shared_ptr<spdlog::logger> default_logger();

};

#define BREAKPOINT(logger) logger->info("breakpoint {}, {}", __FILE__, __LINE__)

#endif // _LIBRARY_LOG_SERVICE_H__
